package resources
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.net.URLRequest;
	import flash.utils.Dictionary;
	
	import global.Global;
	
	public class ResourceManager
	{
		private var _dictionary				: Dictionary;
		private var _loader					: Loader;
		private var _request				: URLRequest;
		
		public function ResourceManager()
		{
		}
		public function init():void {
			_dictionary = Global.resource.dictionary;
		}
		
		public function getResource(key:String):Object {
			if(_dictionary == null) return null;
			var obj:Object;
			if(_dictionary[key] != null) {
				try {
					obj = new _dictionary[key](0, 0);// 是位图
				} catch(error:ArgumentError) {
					obj = new _dictionary[key]();// 不是位图
				}
			}
			return obj;
		}
		public function getBitmapData(key:String):BitmapData {
			return (getResource(key) as BitmapData);
		}
		public function getBitmap(key:String):Bitmap {
			return new Bitmap(getBitmapData(key));
		}
		public function getMovieClip(key:String):MovieClip {
			return (getResource(key) as MovieClip);
		}
	}
}